class EmployeeCertificateValidEnd < ActiveRecord::Observer
  observe EmployeeCertificate

  def before_save record
    record.valid_end = record.valid_from + record.certificate.available_months.month
    record.recheck_time = record.valid_end - record.certificate.recheck_time.to_i.day
  end
end